import CSelectFormItem from '@/components/CSelectFormItem/CSelectFormItem'
import useEffectDictPage from '@/useEffect/useEffectDictPage'
import useEffectUserPage from '@/useEffect/useEffectUserPage'
import { Form } from '@douyinfe/semi-ui'
import { OptionProps } from '@douyinfe/semi-ui/lib/es/select'

export const onlineType: OptionProps[] = [
  { label: '在线', value: 1 },
  { label: '隐身', value: 2 },
]

// 获取 下拉选的数据
export function getErrorLogSearchFormSelectData(modalVisible: boolean) {
  const { dictList } = useEffectDictPage(modalVisible, 'request_category')
  const { userList } = useEffectUserPage(modalVisible, true)
  return { dictList, userList }
}

interface IErrorLogSearchFormItem {
  userList: OptionProps[]
  dictList: OptionProps[]
}

export default function ErrorLogSearchFormItem(props: IErrorLogSearchFormItem) {
  return (
    <>
      <Form.Input field="_id" showClear label="id" />
      <Form.Input field="uri" showClear label="uri" />
      <CSelectFormItem
        field={'createId'}
        label={'请求人'}
        optionList={props.userList}
      />
      <Form.Input field="ip" showClear label="ip" />
      <Form.Input field="region" showClear label="ip区域" />
      <Form.Input field="service" showClear label="请求的服务名" />
      <Form.Input field="port" showClear label="端口" />
      {/* 备注：searchForm设置了值，不管用，必须这里和 searchForm都要设置值才行 */}
      <CSelectFormItem field={'readFlag'} label={'已读'} initValue={0} />
      <CSelectFormItem
        field={'category'}
        label={'类别'}
        optionList={props.dictList}
      />
      <Form.DatePicker
        field="createTimeList"
        label="创建时间"
        type="dateTimeRange"
      />
    </>
  )
}
